//
//  ViewController.m
//  2016-06-06界面
//
//  Created by Roach on 16/6/6.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"
#import "label.h"
#import "TextField.h"
#import "Button.h"
@interface ViewController ()<UITextFieldDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [self creatButton];
    [self creatLabel];
    [self creatTextField];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
// 创建文本框？
- (void) creatLabel {
    // 创建用户名
    label *userLabel = [[label alloc]initWithFrame:CGRectMake(50, 70, 60, 30) withText:@"用户名"];
    [self.view addSubview:userLabel];
    [userLabel release];
    
    // 创建密码
    label *passLabel = [[label alloc]initWithFrame:CGRectMake(50, 120, 60, 30) withText:@"密码"];
    [self.view addSubview:passLabel];
    [passLabel release];
    
    // 创建确认密码
    label *checkPassLabel = [[label alloc]initWithFrame:CGRectMake(50, 170, 80, 30) withText:@"确认密码"];
    [self.view addSubview:checkPassLabel];
    [checkPassLabel release];
    
    // 创建手机号
    label *phoneNumber = [[label alloc]initWithFrame:CGRectMake(50, 220, 60, 30) withText:@"手机号"];
    [self.view addSubview:phoneNumber];
    [phoneNumber release];
    
    // 创建邮箱
    label *Email = [[label alloc] initWithFrame:CGRectMake(50, 270, 60, 30) withText:@"邮箱"];
    [self.view addSubview:Email];
    [Email release];
    
    
}

// 创建编辑框
- (void) creatTextField {
    // 创建用户名
    TextField *userTextField = [[TextField alloc]initWithFrame:CGRectMake(140, 70, 200, 30) withPlaceholder:@"请输入用户名"];
    [self.view addSubview:userTextField];
    [userTextField release];
    
    // 创建密码
    TextField *passTextField = [[TextField alloc]initWithFrame:CGRectMake(140, 120, 200, 30) withPlaceholder:@"请输入密码"];
    [passTextField setTextFieldOther];
    [self.view addSubview:passTextField];
    [passTextField release];
    
    // 创建确认密码
    TextField *checkPassTextField = [[TextField alloc] initWithFrame:CGRectMake(140, 170, 200, 30) withPlaceholder:@"请再次输入密码"];
    [self.view addSubview:checkPassTextField];
    [passTextField setTextFieldOther];
    [passTextField release];
    
    // 创建电话号码
    TextField *phonrNumberTextField = [[TextField alloc]initWithFrame:CGRectMake(140, 220, 200, 30) withPlaceholder:@"请输入电话号码"];
    [self.view addSubview:phonrNumberTextField];
    phonrNumberTextField.keyboardType = UIKeyboardTypeNumberPad;
    [phonrNumberTextField release];
    
    // 创建邮箱
    TextField *Email = [[TextField alloc]initWithFrame:CGRectMake(140, 270, 200, 30) withPlaceholder:@"请输入邮箱"];
    Email.keyboardType = UIKeyboardTypeEmailAddress;
    [self.view addSubview:Email];
    [Email release];
    
    // 指定代理人
    userTextField.delegate = self;
    passTextField.delegate = self;
    checkPassTextField.delegate = self;
    phonrNumberTextField.delegate = self;
    Email.delegate = self;
}

// 创建按钮
- (void) creatButton {
    Button *registerButton = [Button buttonWithType:UIButtonTypeSystem withTitle:@"注册" withFrame:CGRectMake(90, 350, 50, 30)];
    [self.view addSubview:registerButton];
    [registerButton release];

    Button *cancelButton = [Button buttonWithType:UIButtonTypeSystem withTitle:@"取消" withFrame:CGRectMake(220, 350, 50, 30)];
    [self.view addSubview:cancelButton];
    [cancelButton release];
    
}

// 键盘回收

- (BOOL) textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
